﻿using SAIM.Models.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SAIM.Models.BLL
{
    public class AspNetRolesBLL : IDisposable
    {
        private SAIMEntities db;

        public AspNetRolesBLL()
        {
            db = new SAIMEntities();
        }

        /// <summary>
        /// Devuelve una lista con todos los roles de usuario disponibles 
        /// </summary>
        /// <returns></returns>
        public List<AspNetRolesDAL> GetUserRoles()
        {
            List<AspNetRolesDAL> rolesDAL = db.AspNetRoles.ToList().FindAll(r => r.ChildRoles == null);
            /*List<Role> roles = new List<Role>();

            foreach(AspNetRolesDAL role in rolesDAL)
            {
                roles.Add(new Role()
                {
                    Name = role.Name,
                    Id = role.Id
                });
            }*/
            return rolesDAL;
        }

        public void Dispose()
        {
            db.Dispose();
        }
    }
}